package com.xiaochen.utils;

import com.xiaochen.model.entity.system.SysUser;

/**
 * 创建一个线程,
 * 用来保存当前登录用户的信息
 * 确认当前用户是否登录
 */
public class AuthContextUtil  {

    // 创建一个ThreadLocal对象
    private static final ThreadLocal<SysUser> threadLocal = new ThreadLocal<>();

    // 添加数据
    public static void set(SysUser sysUser){
        threadLocal.set(sysUser);
    }

    // 获取数据
    public static SysUser get(){
        return threadLocal.get();
    }

    // 删除数据
    public static void remove(){
        threadLocal.remove();
    }
}
